In computer science, memory management is the act of managing computer memory. In its simpler forms, this involves providing ways to allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. Virtual memory systems separate the memory addresses used by a process from actual physical addresses, allowing separation of processes and increasing the effectively available amount of real memory (e.g. Random Access Memory) using disk swapping. The quality of the virtual memory manager can have a big impact on the overall system performance. Virtual memory is a computer system technique which gives an application program the impression that it has contiguous working memory, while in fact it is physically fragmented and may even overflow on to disk storage. Systems which use this technique make programming of large applications easier and use real physical memory more efficiently than those without virtual memory. Almost all implementations of virtual memory divide the virtual address space of an application program into pages. A page is a block of contiguous virtual memory addresses. Pages are usually fixed in size (at least 2K bytes). Systems with large virtual address ranges or large amounts of real memory generally use larger page sizes
Paging is the process of saving inactive virtual memory pages to disk and restoring them to the real memory when required. This is referred to as disk swapping. Most virtual memory systems enable programs to use virtual address ranges which in total exceed the amount of the real memory. To do this they use disk files to save virtual memory pages which are not currently active, and restore them to the real memory when they are needed. Applications are only aware of virtual addresses. Dynamic address translation is typically done by a memory management unit which looks up in an appropriate page table the real address corresponding to a virtual address and passes the real address to parts of the CPU (Central Processing Unit) which execute instructions. If the page tables indicate that the virtual memory page is not currently in real memory, the hardware raises a page fault. The appropriate page is then loaded on to the real memory for use by the CPU.
In object oriented languages, data objects are typically spread over multiple pages and object references frequently exist between data objects. An object reference to an object which is part of a page that is not currently in the real memory results in a page fault. Loading up a page in the real memory from the disk memory consumes system resources. Furthermore, if the real memory does not have enough space to accommodate a new page, an inactive page must be identified and removed from the real memory to make space for the new page. Thus, a large number of page faults result in the consumption of a considerable amount of system resources and affects the overall system performance.
In typical scenarios where several users initiate transactions simultaneously on a same set of data, a portion of the data changed by one of the users may affect other users. Systems generally deal with such problems by allowing only one user to access the set of data while locking write access to the set of data to all other users. The objects stored in a page typically do not have a strict hierarchy and have multiple loops of object references. An example of a loop is an object A referring an object B, the object B referring an object C and the object C referring the object A. The absence of a strict object hierarchy, the presence of loops of object references and related objects spread over multiple pages makes locking of data very difficult and resource hungry.
In computer systems, garbage collection is the process of automatically freeing objects that are no longer referenced by the program. Garbage collection is typically accomplished by identifying the objects that are no longer referenced and clearing the unreferenced objects to make space for new objects. In case of hardware implemented garbage collectors, it is very difficult to determine whether a content of a memory location is an address to another memory location (a reference) or just an integer. Thus hardware implemented garbage collection is very difficult in current systems.